﻿var trunPageObj;//翻页组件对像

$(initPage);
function initPage() {
	$("#checkItemDiv").attr("scrollTop", '26');//控制DIV滚动条
	
	$(".checkItem", "#checkList").click(function() {
		if($(this).hasClass("selectTD")) {
			return;
		}
	});
	$("#formulaDesc").text($("#check_11", "#checkList").attr("title"));
	$("#check_11", "#checkList").addClass("selectTD").find("img").attr("src","themes/comm/images/open.gif");
	
	
	var jobStatus = $("#jobStatus").val();
	//按扭不可操作
	if (jobStatus == '-2' || jobStatus == "0") {
		$("#reCheck").attr("disabled", true);//不允许再次操作
	}
	
	$("#btnQuery").click(function() {
		$("#data_list").empty();
		trunPageObj.gotoPage(1);//搜索第一页
	});
	
	$("#reCheck").click(function() {
		$("#reCheck").attr("disabled", true);//不允许再次操作
		$.post("m/submit_file/recheck", {
			checkName:"R11"
		}, function(data) {
			if ($.checkErrorMsg(data) ) {
				alert(data.msg.text);
				location.reload();
			} 
		}, "json");
	});
	queryNotPassed();
	//初始化翻页组件
    trunPageObj =  $(".pageNext").turnPage(10, exportList);
    
	trunPageObj.gotoPage(1);//搜索第一页
}

function queryList() {
	var pageno=trunPageObj.getCurrentPageNo();//当前第几页
	var pagecount=trunPageObj.getPageCount();//一页多少条
	$.post("m/data_check/queryr11", {
		pageNo: pageno,
		pageSize : pagecount,
		tradeDate : $.trim($("#tradeDate").val()),
		fundAcct : $.trim($("#fundAcct").val()),
		passed : $.trim($("#passed").val())
	}, function(data) {
		if ($.checkErrorMsg(data) ) {
			var fileList = [];
			if(data.checkR11Page && data.checkR11Page.dataList){
				var dataList = data.checkR11Page.dataList;
				$(dataList).each(function(i) {
					fileList.push("<tr class='table_td_font' bgColor='#ffffff'>");
					fileList.push("<td align='center'  height='25px' class='queryList_linebg' nowrap>" + dataList[i].formatTradeDate + "</td>");
					fileList.push("<td align='left'  height='25px' class='queryList_linebg' nowrap>" + (dataList[i].depName ? dataList[i].depName : "") + "</td>");
					fileList.push("<td align='left'  height='25px' class='queryList_linebg' nowrap>" + dataList[i].fundAcct + "</td>");
					fileList.push("<td align='right'  height='25px' class='queryList_linebg' nowrap>" + dataList[i].currFundBalText + "</td>");
					fileList.push("<td align='right'  height='25px' class='queryList_linebg' nowrap>" + dataList[i].lastFundBalText + "</td>");
					fileList.push("<td align='right'  height='25px' class='queryList_linebg' nowrap>" + dataList[i].exchAmtText + "</td>");
					fileList.push("<td align='right'  height='25px' class='queryList_linebg' nowrap>" + dataList[i].interestAmtText + "</td>");
					fileList.push("<td align='right'  height='25px' class='queryList_linebg' nowrap>" + dataList[i].bondExtrAmtText + "</td>");
					fileList.push("<td align='right'  height='25px' class='queryList_linebg' nowrap>" + dataList[i].totalChgBalText + "</td>");
					fileList.push("<td align='right'  height='25px' class='queryList_linebg' nowrap>" + dataList[i].totalChgBal2Text + "</td>");
					fileList.push("<td align='right'  height='25px' class='queryList_linebg' nowrap>" + dataList[i].totalChgBal3Text + "</td>");
					fileList.push("<td align='right'  height='25px' class='queryList_linebg' nowrap>" + dataList[i].discAmtText + "</td>");
					fileList.push("</tr>");
				});
			}
			$("#data_list").html(fileList.join(""));
			trunPageObj.setPageData(data.checkR11Page);
		} 
	}, "json");
}

function exportList() {
	var obj = window.showModalDialog(BASE_PATH + "page/export_select.jsp","","dialogWidth:200px;dialogHeight:80px;help:no;center:yes;status:no");
	if (obj) {
		window.open("m/data_check/exportr11?tradeDate=" + $.trim($("#tradeDate").val()) + "&fundAcct=" + $.trim($("#fundAcct").val()) + "&passed=" + $.trim($("#passed").val()) + "&expType=" + obj);
	}
}

function changePage(url) {
	if(parseInt(url) < 10){
		url = "0"+url;
	}
	url = "m/data_check/initr"+url;
	location.href=BASE_PATH+url;
}
